
package com.probiz.estore.common.model.product;

import org.apache.commons.lang.StringUtils;

import com.probiz.estore.common.model.product.base.ProductReviewTbl;

/**
 * Model class for ProductReview. Add not database mapped fileds in this class.
 */
public class ProductReview extends ProductReviewTbl {
	/*
	 * ELIGIBLE_PRODUCT_LIST - 客户有资质发表的商品的列表
	 * MY_REVIEW_LIST - 我发表的评论列表
	 * MY_REVIEW_REPLY_LIST - 我发表的回复列表
	 * MY_VOTED_REVIEW_LIST -我认为有用的列表
	 */
	public static enum FilterHqlName{ELIGIBLE_PRODUCT_LIST,MY_REVIEW_LIST,MY_REVIEW_REPLY_LIST,MY_VOTED_REVIEW_LIST};

	public static Short		STATUS_READ		= (short) 1;	// 已读
	public static Short		STATUS_UNREAD	= (short) 0;	// 未读
	public static Short		STATUS_SHOW		= (short) 1;	// 显示
	public static Short		STATUS_UNSHOW	= (short) 0;	// 隐藏
	public static Integer	STATUS_TOP		= 0;			// 置顶
	public static Integer	STATUS_UNTOP	= 10;			// 非置顶
	
	//评论资格 0=匿名 1=登录用户 2=购此商品用户
	public static Short		REVIEW_RIGHT_ANONYMOUS		= (short) 0;	
	public static Short		REVIEW_RIGHT_LOGIN		= (short) 1;	
	public static Short		REVIEW_RIGHT_BUYBEFORE	= (short) 2;	
	
	//回复评论资格 0=匿名 1=登录用户 
	public static Short		REPLY_RIGHT_ANONYMOUS		= (short) 0;	
	public static Short		REPLY_RIGHT_LOGIN		= (short) 1;	

	/**
	 * 获得评论人名称
	 * 
	 * @return
	 */
	public String getReviewUserName() {
		if (null != customer) {
			return customer.getFullName();
		} else {
			return customerName;
		}
	}
	/**
	 * 获得评论人地域地理位置
	 * @return
	 */
	public String getReviewUserArea(){
		String area = "";
		if (StringUtils.isNotBlank(this.getAddress())) {
			String[] addresses = this.getAddress().split(" ");
			area = addresses[0];
		}
		return area;
	}

	/**
	 * 获得前台评论人名称 带地域地理位置
	 * 
	 * @return
	 */
	public String getReviewUserNameWithArea() {
		String area = "";
		if (StringUtils.isNotBlank(this.getAddress())) {
			String[] addresses = this.getAddress().split(" ");
			area = addresses[0]+" ";
		}
		if (null != customer) {
			return area + customer.getFullName();
		} else {
			return area + customerName;
		}
	}

	/**
	 * Default Empty Constructor for class ProductReview
	 */
	public ProductReview() {
		super();
	}

	/**
	 * 定义实体的业务名取值； productReviewName 必须手工完成这个部分，否则编译不通过。
	 */
	public String getProductReviewName() {
		if (productReviewId == null)
			return "";
		else
			// 返回一个指定有业务意义的属性值;
			// 如：product的VO就用product.productName
			return this.productReviewId.toString();
	}

	/**
	 * Default Key Fields Constructor for class ProductReview
	 */
	public ProductReview(Integer in_productReviewId) {
		super(in_productReviewId);
	}

}
